package com.a21200324.upalarm;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;

import java.io.File;

/**
 * Created by malmeida on 6/21/13.
 */
public class TextViewCustomFont extends TextView {

    private static final String TAG = "TextViewCustomFont";

    public TextViewCustomFont(Context context) {
        super(context);
    }

    public TextViewCustomFont(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public TextViewCustomFont(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public boolean setCustomFont(Context ctx, String asset) {
        Typeface tf;

        try {

            tf = Typeface.createFromAsset(ctx.getAssets(),
                    "" + AssetsDefines.FileAssetsDefines.FONTS + File.separator + asset);

            setTypeface(tf);
        } catch (Exception e) {
            Log.e(TAG, "Error to get typeface: " + e.getMessage());
            return false;
        }

        return true;
    }

}
